// JavaScript Document
function getXMLHttpRequest(){
	if(window.ActiveXObject){
		return new ActiveXObject("Microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest){
		return new XMLHttpRequest();	
	}else alert("Status : Can not create XMLHttpRequest Object");
}
var xmlhttp=getXMLHttpRequest();
//function to send data
function sendDataAvatar(handlePage,ElementID){
	var fupload=document.getElementById('fupload').value;
	var username = document.getElementById('username').value;
	if(fupload==""){
		alert("Isi Avatar!");
	}else{
		if(xmlhttp.readyState==4 || xmlhttp.readyState==0){
			var obj=document.getElementById(ElementID);
			var form=obj.innerHTML;
			obj.innerHTML='Saving data, please wait..';
			xmlhttp.open('POST',handlePage,true);
			xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange=function(){
				if(xmlhttp.readyState==4){
					if(xmlhttp.status==200){
						obj.innerHTML=xmlhttp.responseText+'<br>'+form;
					}else{
						alert('Error : '+xmlhttp.statusText);
					}
				}
			}
			var param='fupload='+fupload;
			param+='&username='+username;
			param+='&action=ubahavatar';
			xmlhttp.send(param);
		}
	}
}

function sendDataEmail(handlePage,ElementID){
	var email=document.getElementById('email').value;
	var username = document.getElementById('username').value;
	if(email==""){
		alert("Isi Email!");
	}else{
		if(xmlhttp.readyState==4 || xmlhttp.readyState==0){
			var obj=document.getElementById(ElementID);
			var form=obj.innerHTML;
			obj.innerHTML='Saving data, please wait..';
			xmlhttp.open('POST',handlePage,true);
			xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange=function(){
				if(xmlhttp.readyState==4){
					if(xmlhttp.status==200){
						obj.innerHTML=xmlhttp.responseText+'<br>'+form;
					}else{
						alert('Error : '+xmlhttp.statusText);
					}
				}
			}
			var param='email='+email;
			param+='&username='+username;
			param+='&action=ubahemail';
			xmlhttp.send(param);
		}
	}
}

function sendDataAbout(handlePage,ElementID){
	var about=document.getElementById('about').value;
	var username = document.getElementById('username').value;
	if(about==""){
		alert("Isi About!");
	}else{
		if(xmlhttp.readyState==4 || xmlhttp.readyState==0){
			var obj=document.getElementById(ElementID);
			var form=obj.innerHTML;
			obj.innerHTML='Saving data, please wait..';
			xmlhttp.open('POST',handlePage,true);
			xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange=function(){
				if(xmlhttp.readyState==4){
					if(xmlhttp.status==200){
						obj.innerHTML=xmlhttp.responseText+'<br>'+form;
					}else{
						alert('Error : '+xmlhttp.statusText);
					}
				}
			}
			var param='about='+about;
			param+='&username='+username;
			param+='&action=ubahabout';
			xmlhttp.send(param);
		}
	}
}			